package mirrormonkey.core.module;

import mirrormonkey.core.messages.TimeSyncResponseMessage;
import mirrormonkey.framework.ConnectionInfo;

import com.jme3.network.Message;
import com.jme3.network.MessageConnection;
import com.jme3.network.MessageListener;

public class TimeSyncResponseListener implements
		MessageListener<MessageConnection> {

	public final CoreModule coreModule;

	public TimeSyncResponseListener(CoreModule coreModule) {
		this.coreModule = coreModule;
	}

	@Override
	public void messageReceived(MessageConnection source, Message m) {
		TimeSyncResponseMessage r = (TimeSyncResponseMessage) m;
		ConnectionInfo info = null;
		if ((info = coreModule.getData(source)) != null) {
			info.processTimeSyncResponse(r);
		}
	}
}
